#ifndef TCP_CONNECTOR_H
#define TCP_CONNECTOR_H
#include "io_connector.h"
#include "tcp_connector_config.h"
#include "service_url.h"
#ifdef _USING_ACE
#include "./detail/ace_tcp_connector_impl.h"
#else 
#include "./detail/asio_tcp_connector_impl.h"
#endif

namespace vpm
{
	namespace mina
	{
		using namespace detail;

        template <class Session=TcpSession,class SessionConfigPtr=TcpSessionConfigPtr > 
		class TcpConnector : public IoConnector
		{
		public:
			TcpConnector(TcpConnectorConfigPtr config ,IoHandler& handler):m_tcpConnector(config,handler)
			{
			}

			virtual int connect(const ServiceUrl & peerUrl, const ServiceUrl &localUrl = ServiceUrl("") ) 
			{
				return m_tcpConnector.connect(peerUrl.port,peerUrl.host);
			}
			virtual int disconnect()
			{
				return m_tcpConnector.disconnect();
			}

		private:
			TcpConnectorImpl<Session,SessionConfigPtr> m_tcpConnector;
		};
	}
}

#endif // 
